/**
 *    title:  mysql.hpp
 *    author:  sleeeeeping
 *    created:  2024-09-12 19:21:35
**/
#ifndef _MYSQL_HPP__
#define _MYSQL_HPP__

#include <vector>
#include <iostream>
#include <mysql/mysql.h>

using u32 = unsigned int;

class MySQL {
private:
    MYSQL *mysql;
    std::vector<std::vector<std::string>> result;
public:
    MySQL(void);
    ~MySQL(void);
    bool connect(const std::string &host,
        const std::string &user, const std::string &passwd,
        const std::string &db, u32 port = 3306
        );
    int query(const std::string &sql);
    const std::vector<std::vector<std::string>> &getQueryRestult(void);
    bool getAutoCommit(void);
    bool setAutoCommit(bool isAutoCommit);
    bool commit(void);
    bool rollback(void);
    bool setCharacterSet(const std::string &csname);
    const char* getCharacterSet(void);
    void showError(void);
};

#endif // _MYSQL_HPP__